#!/bin/bash
rm -rf /etc/dracut.conf.d/dracut-test.conf
rm -rf /etc/depmod.d/depmod-test.conf
rm -rf /etc/modprobe.d/modprobe-test.conf
rm -rf /etc/modules-load.d/modules-load-test.conf

cp $(pwd)/dracut-test.conf          /etc/dracut.conf.d/dracut-test.conf
cp $(pwd)/depmod-test.conf          /etc/depmod.d/depmod-test.conf
cp $(pwd)/modprobe-test.conf        /etc/modprobe.d/modprobe-test.conf
cp $(pwd)/modules-load-test.conf    /etc/modules-load.d/modules-load-test.conf

dracut_modules_dir="/usr/lib/dracut/modules.d/90modtest"

clear

rm -rf ${dracut_modules_dir}
mkdir -p ${dracut_modules_dir}
cp $(pwd)/module-setup.sh ${dracut_modules_dir}
chmod 550 ${dracut_modules_dir}/module-setup.sh
echo "module-setup.sh successfully"

tree "${dracut_modules_dir}"

dracut --force
echo "dracut successfully"

lsinitrd | grep -E "test|arkins|modtest"
echo "lsinitrd successfully"
